package com.litchi.tutor.controller;


import com.litchi.tutor.common.entity.Deliver;
import com.litchi.tutor.service.DeliverService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xyouzi
 * @since 2021-11-22
 */
@RestController
@Api("自主投递简历管理")
@RequestMapping("/deliver")
public class DeliverController {

    @Autowired
    DeliverService deliverService;

    @RequestMapping(value = "/autoDeliverByTeacher", method = RequestMethod.POST)
    @ApiOperation("自助投递")
    public ResponseEntity autoDeliverByTeacher(Integer recruitId , HttpServletRequest request) {
        deliverService.autoDeliverByTeacher(recruitId, request);
        return ResponseEntity.ok(null);
    }

    @RequestMapping(value = "/autoDeliverByParent", method = RequestMethod.POST)
    @ApiOperation("自助招募")
    public ResponseEntity autoDeliverByParent(Integer recruitId, Integer teacherId, HttpServletRequest request) {
        deliverService.autoDeliverByParent(recruitId, teacherId, request);
        return ResponseEntity.ok(null);
    }

    @RequestMapping(value = "/queryDeliverByTeacher", method = RequestMethod.GET)
    @ApiOperation("家长查询自己的被投递状态列表/老师查询自己的投递状态列表")
    public ResponseEntity queryDeliverByTeacherOrParent(@RequestParam(required = false) Integer statue) {
        List<Deliver> delivers = deliverService.queryDeliverByTeacherOrParent(statue);
        return ResponseEntity.ok(delivers);
    }

    @RequestMapping(value = "/queryBeRecruitedByTeacher", method = RequestMethod.GET)
    @ApiOperation("老师查询被招募状态列表/家长查询自己的招募状态列表")
    public ResponseEntity queryRecruitedByTeacherOrParent(@RequestParam(required = false) Integer statue) {
        List<Deliver> delivers = deliverService.queryRecruitedByTeacherOrParent(statue);
        return ResponseEntity.ok(delivers);
    }

}

